package com.mengtian_tech.tju.dataquery.api.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

@Configuration
public class ThreadPoolTaskSchedulerConfig {

	@Bean
	public ThreadPoolTaskScheduler taskScheduler() {
		ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
		// 线程池大小设置为10
		scheduler.setPoolSize(10);
		// 确保在关闭时等待任务完成
		scheduler.setWaitForTasksToCompleteOnShutdown(true);
		// 设置最大等待时长，以确保应用最后能够被关闭，而不是阻塞住
		scheduler.setAwaitTerminationSeconds(60);
	
		return scheduler;
	}
}
